package cn.javass.test.action;

import cn.javass.framework.ioc.annotation.IInject;
import cn.javass.framework.web.annotation.IAction;
import cn.javass.framework.web.annotation.IGoto;
import cn.javass.framework.web.core.Action;
import cn.javass.framework.web.core.ActionContext;
import cn.javass.test.model.UserModel;
import cn.javass.test.service.UserService;
@IAction(path="/user",
		 result={@IGoto(key="success",path="test.jsp")}
		)
public class UserAction implements Action{
	@IInject(id="userService")
	private UserService userService;

	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	private UserModel um = new UserModel();

	@Override
	public String execute() {
		System.out.println("======="+um.toString());
		try{
			userService.save(um);
	//		userService.save(um);
		}catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
		um.getAddress().setAddress("zhangjavassp");
		ActionContext.getContext().put("haha", "hahahhahaa");
	//	userService.save(um);
		return "success";
	}

	public UserModel getUm() {
		return um;
	}

	public void setUm(UserModel um) {
		this.um = um;
	}
	
}
